//1.加载/导入 http模块
const http = require('http');
//2.创建服务器对象
const server = http.createServer();
//3.监听服务器，并启动服务器
server.listen(3000,()=>{
  console.log('server is runing...');
});
//4.给服务器注册request事件，并监听浏览器请求
server.on('request',(req,res)=>{
  // console.log(req);
  console.log(req.url);
  if(req.url === '/index' || req.url === '/index.html'){
    res.end('index-page');
  }else if(req.url === '/list' || req.url === '/list.html'){
    res.end('list-page');
  }else{
    res.setHeader('content-type','text/html;charset=utf-8');
    res.end('其他页面');
  };
});